//品牌管理模块
import request from "../../../utils/request"
import { ResponseTrademarkData, TrademarkData } from "./type"

enum API {
  //获取已有品牌接口
  TRADEMARK_URL = "/admin/product/baseTrademark/",
  ADD_TRADEMARK_URL = "/admin/product/baseTrademark/save",
  UPDATE_TRADEMARK_URL = "/admin/product/baseTrademark/update",
  DELETE_TRADEMARK_URL = "/admin/product/baseTrademark/remove",
}

//page 获取第几页
//limit 获取几条数据
export const reqHasTrademark = (page: number, limit: number) =>
  request.get<any, ResponseTrademarkData>(
    API.TRADEMARK_URL + `${page}/${limit}`,
  )

export const reqAddTrademark = (data: TrademarkData) => {
  if (!data.id) {
    return request.post<any, any>(API.ADD_TRADEMARK_URL, data)
  } else {
    return request.put<any, any>(API.UPDATE_TRADEMARK_URL, data)
  }
}

export const reqDeleteTrademark = (id: number) =>
  request.delete<any, any>(API.DELETE_TRADEMARK_URL + `${id}`)
